//
//  MYHelpViewController.m
//  投融保
//
//  Created by 523 on 13-12-19.
//  Copyright (c) 2013年 木叶科技. All rights reserved.
//

#import "MYHelpViewController.h"
#import "MYQuestionCell.h"

@interface MYHelpViewController ()

@end

@implementation MYHelpViewController
@synthesize arrAnswer;
@synthesize arrProblem;
@synthesize questionTable;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    SETBACKGROUND
    //测试数据
    self.arrProblem=[[NSMutableArray alloc] initWithObjects:@"问题1？",@"问题2？",@"问题3？",@"问题4？", nil];
    self.arrAnswer=[[NSMutableArray alloc] initWithObjects:@"回答1？",@"回答2？",@"回答3？",@"回答4？", nil];
    
    [self initView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)initView
{
    Y=0;
    if (IOS_VERSION>=7) {
        Y=20;
    }
    

    
    //导航视图
    UIView *titleView=[[UIView alloc] initWithFrame:CGRectMake(0, Y, SCREEN_WIDTH, 104)];
    [titleView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"titile_bg"]]];
    [self.view addSubview:titleView];
    
    UILabel *lblTitle=[[UILabel alloc] initWithFrame:CGRectMake(284, 12, 200, 80)];
    [lblTitle setText:@"帮助中心"];
    [lblTitle setBackgroundColor:[UIColor clearColor]];
    [lblTitle setTextColor:[UIColor whiteColor]];
    [lblTitle setFont:[UIFont boldSystemFontOfSize:40]];
    lblTitle.textAlignment=NSTextAlignmentCenter;
    [titleView addSubview:lblTitle];
    
    
    UIButton *btnReturn=[UIButton new];
    [btnReturn setFrame:CGRectMake(0, 21, 80, 60)];
    [btnReturn setBackgroundImage:[UIImage imageNamed:@"return_icon"] forState:UIControlStateNormal];
    [btnReturn.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [btnReturn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btnReturn addTarget:self action:@selector(btnReturnClick) forControlEvents:UIControlEventTouchUpInside];
    [titleView addSubview: btnReturn];
    
    
    self.questionTable =[[UITableView alloc] initWithFrame:CGRectMake(0, Y+104, SCREEN_WIDTH, SCREEN_HEIGHT-104-Y)];
    [self.questionTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    self.questionTable.delegate=self;
    self.questionTable.dataSource=self;
    self.questionTable.backgroundColor=[UIColor clearColor];
    self.questionTable.scrollEnabled=NO;
    [self.view addSubview:self.questionTable];
    
    //问题列表视图
//    CGSize resendSize=[str sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(180, 100) lineBreakMode:NSLineBreakByCharWrapping];
    
    
    
    
}

//返回前页按钮方法
- (void)btnReturnClick
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

#pragma mark ++++++++++++++tableView 代理++++++++++++++++++

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"%d",self.arrProblem.count);
    return self.arrProblem.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier=@"reuserIdentifier";
    
    MYQuestionCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    if (cell==nil) {
        NSArray *arr=[[NSBundle mainBundle] loadNibNamed:@"MYQuestionCell" owner:self options:nil];
        cell=[arr objectAtIndex:0];
    }
    cell.backgroundColor=[UIColor clearColor];
    [cell setValueWithQuestionId:[NSString stringWithFormat:@"%d",indexPath.row]  question:[arrProblem objectAtIndex:indexPath.row] answer:[arrAnswer objectAtIndex:indexPath.row]];
    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 145;
}

#pragma mark-   -----------状态栏底色------
- (UIStatusBarStyle)preferredStatusBarStyle
{
    [self.view setBackgroundColor:[UIColor blackColor]];
    return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden
{
    return NO;
}

@end
